Repository navigation
Conversation
The database now has things schema.rb can't describe: PostGIS and other extensions, the topology schema, and functions such as nanoid() used in column defaults (public.barcode). The schema.rb dumped from it couldn't be loaded into a fresh database, so test databases and new machines couldn't be set up. structure.sql, written by pg_dump, keeps all of it. - schema_format :sql, dumping every schema so the extensions' own come along - the dump leaves out owners and grants, which are roles on the machine it came from and would stop it loading elsewhere - db/schema.rb is removed; db/structure.sql has to be dumped from a database that has those objects Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
db/schema.rbfrom 7f502da can't be loaded into a fresh database, so test databases and new machines can't be set up. It was dumped from a database with thingsschema.rbcan't describe (PostGIS and other extensions, thetopologyschema,public.barcodewith ananoid(13)default). This switches todb/structure.sql, written bypg_dump:config.active_record.schema_format = :sqlconfig.active_record.dump_schemas = 'public'(changed from:allin 27922e4)--no-owner --no-privilegesfor the dump (config/initializers/structure_dump.rb), since owners and grants are roles on the machine it came fromdb/schema.rbremoveddb/structure.sqladded (27922e4, 7,756 lines)Status: the committed structure.sql doesn't load into a fresh database yet
I loaded the pushed file into a fresh PostgreSQL 16 database (
rails db:schema:load). It stops at the first error, and a lenient load shows why:SET transaction_timeout = 0;, which PostgreSQL 16 rejects. (It was dumped by a 17+pg_dump.)CREATE SCHEMA public;fails on any database that already has apublicschema, which is every new one.CREATE EXTENSIONlines. Withdump_schemas = 'public',pg_dumpleaves extensions out, sopublic.geometry(PostGIS) doesn't exist when the tables and views that use it are created.areas,locations,farm_fields0,barcode,oban_jobs,analysis_labs,2_ed_lux_arbor_microplots), and there are 18 views (for examplekbs013_001_2,mle_polygons,n2o_project_weather). Several views read other schemas (weather,kbs013,kbs019,kbs020,test) that the dump doesn't include, so they can't be created. Nothing inapp/,lib/,config/or the specs uses PostGIS,nanoid()orbarcode.A lenient load on 16 (with items 1 and 2 stripped) reports 569 errors, mostly from 3 and 4, and the test database ends up without several app tables.
Likely fix (not done yet)
Dump from a scratch database that holds only the app: load the schema from before 7f502da, run the migrations, then
bin/rails db:schema:dump. That contains only the app's objects, loads on PostgreSQL 16 and later, and drops the research tables and views from the Rails schema. If the app really does need PostGIS ornanoid(), they should be added by a migration (enable_extension,CREATE FUNCTION) instead of coming along in the dump.Testing
nanoid(): a dump withdump_schemas = :allloaded into a fresh test database, and the full suite passed (307 examples, 0 failures).db/structure.sql(27922e4) was not loadable, as described above; the suite was not run against it.lib/parser_test.rbstill loadsdb/schema.rb; it's an old SQLite script and is left as is.🤖 Generated with Claude Code
https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7